package com.shujia.wc;

import java.io.BufferedWriter;
import java.io.FileWriter;

public class MakeData {
    public static void main(String[] args) throws Exception {


        FileWriter fileWriter = new FileWriter("java/data/big_words.txt");

        BufferedWriter writer = new BufferedWriter(fileWriter);

        for (int i = 0; i < 20000000; i++) {

            StringBuilder line = new StringBuilder();

            for (int j = 0; j < 20; j++) {
                String word = randomWord();
                line.append(word);
                line.append(",");
            }
            //删除最后一个字符
            line.deleteCharAt(line.length() - 1);

            writer.write(line.toString());
            writer.newLine();

        }

        writer.close();


    }


    public static String randomWord() {

        String words = "qwertyuiopasdfghjklzxcvbnm";

        StringBuilder buffer = new StringBuilder();

        int length = (int) (Math.random() * 4 + 3);

        for (int i = 0; i < length; i++) {

            int index = (int) (Math.random() * words.length());

            char c = words.charAt(index);

            buffer.append(c);

        }
        return buffer.toString();
    }
}
